import 'package:easy_refresh/easy_refresh.dart';
import 'package:flutter/material.dart';
import 'package:junyeyishu/utils/ScreenFit.dart';
import 'package:junyeyishu/widgets/QGNavigationBar.dart';

class recordPage extends StatefulWidget {
  const recordPage({super.key});

  @override
  State<recordPage> createState() => _SettingPageState();
}

//  huode
class _SettingPageState extends State<recordPage> {
  onload() {}
  bool _isLoading = true;

  final ScrollController _scrollController = ScrollController();

  @override
  void initState() {
    super.initState();
    _scrollController.addListener(_loadMore);
  }

  _fetchData() {}

  void _loadMore() {
    if (_scrollController.position.pixels ==
        _scrollController.position.maxScrollExtent) {
      // 如果当前没有在加载并且还有更多数据

      print('object');
      if (!_isLoading) {
        _fetchData(); // 加载下一页数据
      }
    }
  }

  final List<Map<String, String>> _items = [
    {"title": "ddddd", "time": "ddddd"},
    {"title": "ddddd", "time": "ddddd"},
    {"title": "ddddd", "time": "ddddd"},
    {"title": "ddddd", "time": "ddddd"},
    {"title": "ddddd", "time": "ddddd"},
    {"title": "ddddd", "time": "ddddd"},
    {"title": "ddddd", "time": "ddddd"},
    {"title": "ddddd", "time": "ddddd"},
    {"title": "ddddd", "time": "ddddd"},
    {"title": "ddddd", "time": "ddddd"},
    {"title": "ddddd", "time": "ddddd"},
    {"title": "ddddd", "time": "ddddd"},
    {"title": "ddddd", "time": "ddddd"},
   
  ];

  @override
  void dispose() {
    _scrollController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: [
          Stack(
            children: [
              Positioned(child: buildTop()),
            ],
          ),
          
          Expanded(child: 
          Container(
                margin: EdgeInsets.symmetric(horizontal: 15, vertical: 15),
                decoration: BoxDecoration(
                    color: Color(0XFF232A32),
                    borderRadius: BorderRadius.circular(15.rpx)),
                child: 
                 ListView.builder(
                  shrinkWrap: true, // 关键属性
                  controller: _scrollController, // 绑定控制器
                  //  physics: NeverScrollableScrollPhysics(),  // 禁用滚动
                  itemCount: _items.length,
                  itemBuilder: (context, index) {
                    return Container(
                      padding: EdgeInsets.symmetric(
                          horizontal: 13.rpx, vertical: 13.rpx),
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: [
                              Text('超现',
                                  style: TextStyle(
                                      fontSize: 16, color: Color(0XFFFFFFFF))),
                              Text('2025-05-26 16:00:00',
                                  style: TextStyle(
                                      fontSize: 12, color: Color(0XFF989EA4))),
                            ],
                          ),
                          Text('超现',
                              style: TextStyle(
                                  fontSize: 16, color: Color(0XFFFFFFFF))),
                        ],
                      ),
                    );
                  },
                ),
            
          )
          )
        
        ],
      ),
    );
  }

  buildTop() {
    return Container(
      color: Color(0XFF0c1012),
      child: QGNavigationBar(
          title: "中奖记录",
          rightItem: Container(
            margin: EdgeInsets.only(right: 15.rpx),
            child: Text('',
                style: TextStyle(fontSize: 16, color: Color(0XFFFFFFFF))),
          )),
    );
  }
}
